package com.wxzz.elearing.pay.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wxzz.elearing.pay.entity.UserOrder;
import com.wxzz.elearing.pay.vo.SelectAllIncomePriceVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;

/**
 * <p>
 * 用户订单表 Mapper 接口
 * </p>
 *
 * @author
 * @since 2021-04-23
 */
public interface UserOrderMapper extends BaseMapper<UserOrder> {

    @Select("SELECT\n" +
            "\tSUM( income_price ) amount,COUNT(1) orderNum\n" +
            "FROM\n" +
            "\tuser_order \n" +
            "WHERE\n" +
            "\torder_status = 1 \n" +
            "\tAND deleted = 0 \tAND model_type = #{modelType}\n" +
            "\tAND create_time BETWEEN #{startTime} \n" +
            "\tAND #{endTime}")
    SelectAllIncomePriceVo selectAllIncomePrice(@Param("modelType") Integer modelType, @Param("startTime") String startTime, @Param("endTime") String endTime);

    @Select("SELECT\n" +
            "\tSUM( income_price ) amount,COUNT(1) orderNum\n" +
            "FROM\n" +
            "\tuser_order \n" +
            "WHERE\n" +
            "\torder_status = 1 \n" +
            "\tAND deleted = 0 " +
            "\tAND create_time BETWEEN #{startTime} \n" +
            "\tAND #{endTime}")
    SelectAllIncomePriceVo selectAllIncomePriceToday(@Param("startTime") String startTime, @Param("endTime") String endTime);

}
